package com.general.framework.mq;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class MqProducer {
    @Resource
    private final RocketMQTemplate rocketMQTemplate;

    public MqProducer(RocketMQTemplate rocketMQTemplate) {
        this.rocketMQTemplate = rocketMQTemplate;
    }

    /**
     * 发送消息
     */
    public void send(String topic, String msg) {
        rocketMQTemplate.convertAndSend(topic, msg);
    }
}
